package com.tool.configuration.interceptor.config;

import com.tool.configuration.interceptor.CheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 酒徒
 * @Version 1.0
 * @data 2024/1/25 13:00
 * 注册自定义拦截器
 * todo: 修改拦截路径和放行路径
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private CheckInterceptor checkInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkInterceptor)
                .addPathPatterns("/**") //拦截路径
                .excludePathPatterns("/interceptor/login"); //放行路径
    }
}
